import {ProjectPayloadType} from "@/schemas/project.ts";
import {DsPayloadType} from "@/schemas/datasource.ts";
import {AiConfigPayloadType} from "@/schemas/ai.ts";

type CommonPayloadType = "ListQuery" | "Pagination"

type FilterFuncType = "in" | "like" | "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "null" | "notnull"

export type PayloadType = CommonPayloadType | ProjectPayloadType | DsPayloadType | AiConfigPayloadType

export type Payload<T> = {
    type: PayloadType;
    data: T;
}

export type DuckQuery = {
    id: string;
}

export type ListQuery = {
    pagination: {
        page: number;
        pageSize: number;
    };
    filters?: Array<{
        field: string;
        value: string | number | boolean | Array<string>;
        func: FilterFuncType;
    }>
    orderBy?: Array<{
        field: string;
        desc: boolean;
    }>;
}

export type ListResult<T> = {
    result?: Array<T>;
    total?: number;
}

export type EffectOne<T> = {
    effect?: T
}

export type InvokeResult<T> = {
    data: T;
    type: string;
}


export type InvokeResponse<T> = {
    data?: T;
    type?: string;
    ok: boolean;
}
